<?php

	if($file = upload("image")){

		ini_set('memory_limit', '48M');

		$_POST["image"] = $file[0];

		$image = new Image();

		$image->load($file[1]);
		$image->maxWidth(680);
		$image->maxHeight(400);
		$image->save($file[1]);

		$image->load($file[1]);
		$image->resizeAndCrop(90, 60);
		$image->save(Files::add_prefix($file[1],"-th"));

		$_POST['thumb'] = Files::add_prefix($file[0],"-th");
	}

	$db->update("gallery_picture", $_POST, "id='$id'");

	redirect("index.php?gid=$gid");
?>